from concurrent.futures import ThreadPoolExecutor
import requests
import uuid
import json
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from model.car_number import CarNumber

from common.logger import logger
from account.ydt_account_service import YdtAccountService
from spider.ydt_park import YdtParkSpider
import spider_config

# 生成guid


def test():
    service = YdtAccountService()
    service.active()
    while True:
        try:
            spider = YdtParkSpider()
            spider.setAccount(service.take())
            # spider.setProxy(proxy)
            logger.success(spider.query(CarNumber("川B777MU")))
        except Exception as e:
            logger.exception(e)


if __name__ == "__main__":
    thread_count = 1

    thread_pool = ThreadPoolExecutor(max_workers=thread_count)

    futures = []
    for i in range(thread_count):
        futures.append(thread_pool.submit(test))

    thread_pool.shutdown(wait=True)
